partial derivatives for gate